<?php 
session_start(); 
if(!isset($_SESSION['install'])) 
  {
    header('Location: ../');
  }

$CONF['langue'] = $_SESSION['langue'];
include('../php/langue.php');

$m = '';

if(!empty($_POST['type']) &&
   !empty($_POST['user']) &&
   !empty($_POST['password']) &&
   !empty($_POST['host']) &&
   !empty($_POST['nom']))
  {
    
    $prefix = (!empty($_POST['prefix'])) ? $_POST['prefix'] : '';

    $CONFf =
'<?php
$CONF[\'sql_type\']   = \''.$_POST['type'].'\';
$CONF[\'sql_user\']   = \''.$_POST['user'].'\';
$CONF[\'sql_pass\']   = \''.$_POST['password'].'\';
$CONF[\'sql_host\']   = \''.$_POST['host'].'\';
$CONF[\'sql_db\']     = \''.$_POST['nom'].'\';
$CONF[\'sql_prefix\'] = \''.$prefix.'\';
?>
';

    if(@fwrite(@fopen('../config_.php', 'a'), $CONFf) === false)
      {
	$m = $LANG[9];
      }
    else
      {

	require_once '../php/fonctions.php';
	$nofonctions = true;
	require_once '../config_.php';
	require_once '../php/SQL.php';

	try
	  {
	    $sql = SQL::GetInstance();
	    header('Location: step-3.php');
	  }
	catch(Exception $e)
	  {
	    //echo $e->getMessage();
	    @unlink('../config_.php');
	    $m = $LANG[46];
	  }
      }

}

include('top.php');

?>
<h1><?php echo $LANG[10]; ?></h1>
<blockquote class="info">
<form action="step-2.php" method="post">
<div>
<label for="a1">
  <?php echo $LANG[11]; ?><br /><input id="a1" type="text" name="type" value="mysql" /><br />
</label> 
<label for="a2">
  <?php echo $LANG[12]; ?><br /><input id="a2" type="text" name="user" value="" /><br />
</label>
<label for="a3">
  <?php echo $LANG[13]; ?><br /><input id="a3" type="password" name="password" value="" /><br />
</label>
<label for="a4">
  <?php echo $LANG[14]; ?><br /><input id="a4" type="text" name="host" value="127.0.0.1" /><br />
</label>
<label for="a5">
  <?php echo $LANG[15]; ?><br /><input id="a5" type="text" name="nom" value="" /><br />
</label>
<label for="a6">
  <?php echo $LANG[16]; ?><br /><input id="a6" type="text" name="prefix" value="lst_" /><br />
</label>
<input type="submit" value="<?php echo $LANG[17]; ?>" />
</div>
</form>
</blockquote>
<?php 
  if(!empty($m)) echo '<blockquote class="error">'.$m.'</blockquote>'; 
include('bottom.php');
?>
